package com.example.litehdfs.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.litehdfs.config.ResponseMsg;
import com.example.litehdfs.model.dto.UserLoginInfo;
import com.example.litehdfs.model.req.UserLoginReq;
import com.example.litehdfs.service.UserService;

import lombok.extern.slf4j.Slf4j;

/**
 * 用户相关接口，拦截
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 用户登录注册
     */
    @PostMapping("/login")
    public ResponseMsg<UserLoginInfo> login(@RequestBody UserLoginReq req) {
        return ResponseMsg.ofSuccess(userService.login(req));
    }
    

    /**
     * 查询用户信息
     */
    @PostMapping("/getUserInfo")
    public ResponseMsg<UserLoginInfo> getUserInfo() {
        return ResponseMsg.ofSuccess(userService.getUserInfo());
    }
}
